MS Outlook ulozeni priloh

Otázka od: janpolasek@vol.cz

19. 11. 2002 16:13

Pratele:
Prosel jsem uz archivy Delphi konference i
konference na Builderu a ani 1001 T+T mi nepomohlo.

O co jde ?

Mam D4 prof a pomoci OLE jsem napsal s pomoci prikladu
delphi3000.com proceduru na stahovani dennich davek datovych souboru
A slozenek
Ceske posty - viz nize zdrojak.
Program bezel dva roky celkem bez problemu, pomoci MS Outlooku
projde slozku Dorucena posta a z doslych emailu vyfiltruje prilohy
a ulozi do urceneho pracovniho adresare, kde dojde k rozsifovani
atd. Chodilo to s Outlookem 97 a pak i s Outlookem 2000

Problem je v tom, ze od urcite doby to prestalo chodit a to tak, ze:

- prilohy starsich nevymazanych emailu, ktere Outlook zobrazuje v
jednom okne s textem emailu se nactou jako driv OK

- novejsi emaily Outlook zobrazuje jinak : maji text v jednom okne a
  prilohy ve spodnim uzkem okne.
  Tyto prilohy uz program nenacte.
  
Asi doslo k nejakemu nastaveni formatu emailu, ale neumim to vratit,
nebo
Odesilatele pouzivaji jiny format?
nebo to dela AVG ?

kazdopadne nejsou soubory techto priloh specifikovane jako
oMsg.Attachments.item(Counter).FileName (viz nize)

Dotaz 1. Prosim, neresil jsi tento problem ? (je to nastavenim
Outlooku, nebo se da odkazovat jinak na prilohy?)


Dotaz 2. toto nyni neni akutni, ale lze programove provest move
         zprac.emailu do jine uzivatelem definovane slozky Outlooku?

diky za radu

Jan Polasek Zlin


function TFOutlReadPKA.ManageAttachments(SendersName, AttachmentPath
: string; MailDelete : boolean):boolean;

var
  oApp : variant;
  oNs : variant;
  oFolder : variant;
  oMsg : variant;
  AtC : variant;
  AttFileName : variant;
  FileName : string;
  CheckSender : string;
  Counter : integer;
  MailCounter : integer;
  i : byte;
  Den : TDateTime;
  STime : string[8];
  PredmetEmailu: string;
  SS : string;
  EAdr,
  oCilSlozka : variant;

begin

  i := 0;

  try
    oApp := CreateOLEObject('Outlook.Application');

    try
      oNs := oApp.GetNamespace('MAPI');

      ofolder := oNs.GetDefaultFolder(6); // FolderTypeEnum
(olFolderInbox)

      MailCounter := 1;
      // If there is any email in the Inbox - v Dorucene poste
      if ofolder.items.count > 0 then (* polozky ve slozce *)
      begin
        repeat
          // Get the first Email
          oMsg := ofolder.items(MailCounter);
(* čas vzniku emailu *)
          Den := oMsg.CreationTime;
ShowMessage(DateToStr(Den));
// Check the name or Email
(* výběr podle předmětu emailu *)
          // use CheckSender := oMsg.subject to search on Subject;
          PredmetEmailu:= oMsg.subject;
          CheckSender := oMsg.sendername;
          Label4.Caption := CheckSender;

(* výběr dle datumu od-do *)
          with DataModule1 do
          if ((Den >= OdData)and(Den <= DoData)) then


          if copy(CheckSender,1,6) = copy(SendersName,1,6)then
          
          begin
            // Check how many attachments - pocet priloh
            atc := oMsg.Attachments.count;

            if atc > 0 then
            begin
              // Get all the attachments and save them
              for Counter := 1 to atc do
              begin
                AttFileName :=
oMsg.Attachments.item(Counter).FileName; FileName
:= AttachmentPath+'\'+AttFileName;

                oMsg.Attachments.Item(Counter).SaveAsFile(FileName);

                STime := LeveNuly(ToRight(TimeToStr(Den),8));
                Memo1.Lines[i] := FileName+' '+#09+
                                  DateToStr(Den)+' '+
                                  STime+' '+
                                  CheckSender+#13+#10;
                inc(i);
                Update;
                Application.ProcessMessages;
              end;
            end;
            (* zruseni zpracovaneho mailu - zatim ne
            if MailDelete then
            begin
              oMsg.delete;
              // There's 1 Email less, so MailCounter - 1
              dec(MailCounter);
            end;
            *)
          end;
          // Get the next Email
          inc(MailCounter);
          // Do until there is no more Email to check
        until MailCounter > ofolder.items.count;
      end;
    finally
      (*oApp.quit; *)(* vypne Outlook *)
    end;
  except
    result := false;
    exit;
  end;
    result := true;
end;